package com.houdoudou.servlet.jsp;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.houdoudou.affair.jsp.Common;
import com.houdoudou.affair.jsp.OwnerAffairJsp1;

public class Owner4Jsp extends HttpServlet {

	private static final long serialVersionUID = 7L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		process(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		process(req, resp);
	}
	
	void process(HttpServletRequest req, HttpServletResponse resp){
		
		String affair="";
		    try {
				req.setCharacterEncoding("UTF-8");
				  resp.setCharacterEncoding("UTF-8");
					 affair=req.getParameter("affair");
					 System.out.println("affair="+affair + "  时间----"+ new Date());
		    } catch (UnsupportedEncodingException e) {
			    // TODO Auto-generated catch block
		    	 String jumpJspPath="/programmer/basicResult.jsp";
		    	  String errorInfo="无法解析事件";
					Common.forwardToJsp(req,resp,jumpJspPath,errorInfo);
			    e.printStackTrace();
			    return;
	         	 }	 
					 
		 //业主登陆
		 if(affair.equals("login")){ 
			  OwnerAffairJsp1.login(req, resp);
		 } //创建自提柜分配
		 else  if(affair.equals("createDistribute")){ 
			  OwnerAffairJsp1.createDistribute(req, resp);
		 }//保存自提柜分配
		 else  if(affair.equals("saveDistribute")){ 
			  OwnerAffairJsp1.saveDistribute(req, resp);
		 }//搜索自提柜分配
		 else  if(affair.equals("searchDistribute")){ 
			  OwnerAffairJsp1.searchDistribute(req, resp);
		 }
		 
		 else{
			 String jumpJspPath="/programmer/basicResult.jsp";
			 String errorInfo="事件   "+ affair  +"未定义";
				Common.forwardToJsp(req,resp,jumpJspPath,errorInfo); 
		 }
		 
		    }
	
}
